import { useState } from "react"
function useUpdateInput(initVal) {
	const [value, setValue] = useState(initVal)
	return {
		value,
		onChange: event => setValue(event.target.value)
	}
}

export function Test17() {
	const nameInput = useUpdateInput('')
	const passwordInput = useUpdateInput('')
	const submit = event => {
		event.preventDefault()
		console.log(nameInput.value, passwordInput.value)
	}
	return (
		<>
			<h1>17.自定义Hook2</h1>
			<form onSubmit={submit}>
				<input type='text' name="name" {...nameInput} />
				<input type='password' name="password" {...passwordInput} />
				<input type='submit' />
			</form>
		</>

	)
}